#include "gmw.hpp"
#include <algorithm>

class EchoFunction : public GearmanWorkerFunction
{
protected:
	virtual bool implementation(const std::string &arg) {
		retData_ = arg;
		return true;
	}
public:
	EchoFunction() : GearmanWorkerFunction("echo") {}
	~EchoFunction() {}
};

class ReverseFunction : public GearmanWorkerFunction
{
protected:
	virtual bool implementation(const std::string &arg) {
		retData_ = arg;
		std::reverse(retData_.begin(), retData_.end());
		return true;
	}
public:
	ReverseFunction() : GearmanWorkerFunction("reverse") {}
	~ReverseFunction() {}
};

int main() {
	std::vector<boost::shared_ptr<GearmanWorkerFunction> > v;
	v.push_back(boost::shared_ptr<GearmanWorkerFunction>(new ReverseFunction()));
	v.push_back(boost::shared_ptr<GearmanWorkerFunction>(new EchoFunction()));

	GearmanWorker gw(v);
	gw.Run();

	return 0;
}
